//
//  XQSettingViewController.m
//  XQClock
//
//  Created by 孙强 on 2024/8/9.
//

#import "XQSettingViewController.h"
#import "XQPromptViewController.h"
#import "XQMembershipViewController.h"

@interface XQSettingViewController ()

@end

@implementation XQSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.view.backgroundColor = UIColor.whiteColor;
    
    self.navigationView.title = REAPPString(@"Settings");
    
    [self setUpSubViews];
    
    
}

- (void)setUpSubViews {
    
    NSArray *imageArr = @[@"Mask group",@"Rectangle 8",@"Rectangle 9"];
    NSArray *titleArr = @[@"Unlock Clock Membership",@"How to add \ndesktop widgets?",@"About Us"];
    NSArray *imageSubArr = @[@"Rectangle 7",@"Group 8",@"Union"];

    
    for (int i = 0; i < imageArr.count; i++) {
        
        UITapGestureRecognizer *infoTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(infoTap:)];
        
        UIImageView *mainImageView = [[UIImageView alloc] init];
        [self.view addSubview:mainImageView];
        [mainImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
            make.width.equalTo(690/2 * GJWidth);
            if (i == 0) {
                make.top.equalTo(NavigationHeight);
                make.height.equalTo(230/2 * GJWidth);
            } else if (i == 1){
                make.top.equalTo(NavigationHeight + 125*GJWidth);
                make.height.equalTo(180/2 * GJWidth);
            }else if (i == 2){
                make.top.equalTo(NavigationHeight + 450*GJWidth / 2);
                make.height.equalTo(100/2 * GJWidth);
            }
            
        }];
//        ViewBorderRadius(mainImageView, 29, 0, COLOR_MAIN);
        mainImageView.userInteractionEnabled = YES;
        mainImageView.contentMode = UIViewContentModeScaleAspectFill;
        mainImageView.clipsToBounds = YES;
        mainImageView.image = [UIImage imageNamed:[imageArr objectAtIndex:i]];
        mainImageView.tag = 1000 + i;
        
        [mainImageView addGestureRecognizer:infoTap];
        
        
        UILabel *titleLabel = [[UILabel alloc] init];
         titleLabel.font = [UIFont systemFontOfSize:16*GJWidth];
         titleLabel.text = [titleArr objectAtIndex:i];
         [mainImageView addSubview:titleLabel];
        titleLabel.numberOfLines = 2;
        titleLabel.textColor = UIColor.blackColor;
        
        if (i == 0) {
            titleLabel.font = [UIFont boldSystemFontOfSize:18*GJWidth];
            titleLabel.textColor = UIColor.whiteColor;
        }
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(24*GJWidth);
            
            if (i == 0) {
                make.top.equalTo(24*GJWidth);
                make.height.equalTo(21 * GJWidth);
            } else if (i == 1){
                make.centerY.equalTo(mainImageView);
            }else if (i == 2){
                make.centerY.equalTo(mainImageView);

            }
        }];
        
        
        UIImageView *subImageView = [[UIImageView alloc] init];
        [mainImageView addSubview:subImageView];
        [subImageView mas_makeConstraints:^(MASConstraintMaker *make) {

            if (i == 0) {
                make.left.equalTo(24*GJWidth);
                make.bottom.equalTo(-24*GJWidth);
                make.size.equalTo(CGSizeMake(110*GJWidth, 32*GJWidth));
            } else if (i == 1){
                make.left.equalTo(506/2*GJWidth);
                make.size.equalTo(CGSizeMake(40*GJWidth, 138/2*GJWidth));            make.centerY.equalTo(mainImageView);
            }else if (i == 2){
                make.left.equalTo(506/2*GJWidth);
                make.size.equalTo(CGSizeMake(75/2*GJWidth, 28/2*GJWidth));            make.centerY.equalTo(mainImageView);
            }
            
        }];
        subImageView.image = [UIImage imageNamed:[imageSubArr objectAtIndex:i]];
        
        if (i == 0) {
            

            
            
            
        }

        
        
        
        
    }
    
    
    
    
    
}


- (void)infoTap:(UITapGestureRecognizer *)tap{
    
    
    
    switch (tap.view.tag - 1000) {
        case 0:
        {
            XQMembershipViewController *vc = [XQMembershipViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            
            break;
        case 1:
        {
            XQPromptViewController *vc = [XQPromptViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        default:
            break;
    }
     
    
}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
